home *** CD-ROM | disk | FTP | other *** search
- #ifndef MODULESUPPORT_H
- #define MODULESUPPORT_H
-
- /* This file defines some utility types, functions, and macros used in
- * Module.h and files which depend on it.
- */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Files.h>
- #include <stddef.h>
-
-
- /* These macros are used to specify the usage of parameters passed by
- * reference or as a pointer.
- */
- #undef IN
- #undef OUT
- #undef IO
- #define IN // parameter is read-only (equivalent to const).
- #define OUT // parameter is write-only.
- #define IO // parameter is both read and written.
-
-
- /* This macro is used in front of a pointer declaration to indicate that
- * the object pointed to is "owned" by the object containing the declaration
- * (i.e. will be disposed of by the object's destructor). When used in front
- * of a parameter or function result declaration, it indicates that ownership
- * of the pointer is being transferred into or out of the function.
- */
- #undef OWN
- #define OWN
-
-
- /* These standard types are used to represent 32-bit, 16-bit, and 8-bit
- * integers; characters; and double-precision floating point values. Note
- * that “Byte” with no u or s prefix is unsigned, even though “Short” and
- * “Integer” are signed; this is mainly for compatability with types.h, which
- * defines Byte as unsigned char.
- */
- typedef signed long Integer;
- typedef unsigned long uInteger;
- typedef signed short Short;
- typedef unsigned short uShort;
- typedef unsigned char Byte;
- typedef signed char sByte;
- typedef unsigned char Character;
- typedef double Float;
-
- typedef void* voidPtr;
- typedef Integer* IntegerPtr;
- typedef uInteger* uIntegerPtr;
- typedef Short* ShortPtr;
- typedef uShort* uShortPtr;
- typedef Byte* BytePtr;
- typedef sByte* sBytePtr;
- typedef Character* CharacterPtr;
- typedef Float* FloatPtr;
-
-
- inline Integer Min(Integer a, Integer b) { return (a<b ? a : b); }
- inline Integer Max(Integer a, Integer b) { return (a>b ? a : b); }
-
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- extern void DebugMsg(const char* msg);
-
- #ifdef __cplusplus
- }
-
- /* This mess exists to define the Assert macro. Assert takes one parameter which
- * should be an expression that evaluates to a boolean result. If the result is
- * true, it does nothing; if the result is false, it traps to the debugger with
- * a message of the form “Assertion failed: ‘foo >= 0’”, where foo >= 0 is
- * replaced by whatever your expression was. If the ModuleDebug flag is turned
- * off, no object code is created for Assert calls.
- */
- #if ModuleDebug
- inline void AssertMsg(Boolean assertion, const char* message)
- {
- if (!assertion)
- DebugMsg((char*)message);
- }
- #define Assert(x) AssertMsg(x, "Assertion failed: “" #x "”")
- #else
- #define AssertMsg(x,y)
- #define Assert(x)
- #endif
-
- #endif // __cplusplus
-
- #endif // ifndef MODULESUPPORT_H
-